<template>
  <div class="app-container">

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-sort"
          size="mini"
          @click="toggleExpandAll"
        >展开/折叠</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table
      v-if="refreshTable"
      v-loading="loading"
      :data="deptList"
      row-key="deptId"
      :default-expand-all="isExpandAll"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
      :max-height="maxHeight"
      style="width: 100%;"
    >
      <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
      <el-table-column prop="deptId" label="部门编号" width="260"></el-table-column>
      <el-table-column prop="highEducationalLevel0" label="初中及以下" width="120"></el-table-column>
      <el-table-column prop="highEducationalLevel1" label="中专" width="120"></el-table-column>
      <el-table-column prop="highEducationalLevel2" label="高中" width="120"></el-table-column>
      <el-table-column prop="highEducationalLevel3" label="大专" width="120"></el-table-column>
      <el-table-column prop="highEducationalLevel4" label="本科" width="120"></el-table-column>
      <el-table-column prop="highEducationalLevel5" label="硕士" width="120"></el-table-column>
      <el-table-column prop="highEducationalLevel6" label="博士" width="120"></el-table-column>
    </el-table>

  </div>
</template>

<script>
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getcountbygenderApi, getEducationalLeveList} from "@/api/Empment/DataStatistics";

export default {
  name: "Dept",
  dicts: ['sys_normal_disable'],
  components: { Treeselect },
  data() {
    return {
      deptData: [],
      loading: false,
      showSearch: true,
      deptList: [],
      isExpandAll: true,
      refreshTable: true,
      maxHeight: window.innerHeight * 0.8, // 表格最大高度占屏幕的80%
    };
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      this.loading = true;
      getEducationalLeveList().then(response => {
        this.deptList = this.handleTree(response.data, "deptId");
        this.loading = false;
      },);
    },
    toggleExpandAll() {
      this.isExpandAll = !this.isExpandAll;
    }
  }
};
</script>
